package tg.app.rj.cuwo.virtual;

import java.rmi.RemoteException;

import psdi.app.common.virtual.ChangeStatusSet;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboServerInterface;
import psdi.mbo.MboSet;
import psdi.mbo.MboSetRemote;
import psdi.mbo.NonPersistentMboSetRemote;
import psdi.mbo.SqlFormat;
import psdi.util.MXException;
import tg.app.rj.cuwo.CuwoRemote;


public class CuwoChangeStatusSet extends ChangeStatusSet implements
		NonPersistentMboSetRemote {
	private static final long serialVersionUID = 1L;

	public CuwoChangeStatusSet(MboServerInterface mboserverinterface)
			throws MXException, RemoteException {
		super(mboserverinterface);
	}

	protected MboSetRemote getMboIntoSet(MboRemote mboremote)
			throws MXException, RemoteException {

		// MboSetRemote mbosetremote =
		// getMboServer().getMboSet("WORKTICKET",getUserInfo());

		// MboSetRemote changeFVSet =
		// getMboServer().getMboSet(mbo.getName(),getUserInfo());
		// String sqlformat = mbo.getName() + "NUM=:" + mbo.getName() + "NUM";
		// SqlFormat sqlformat = new SqlFormat(mbo, sql);

		// SqlFormat sqlformat = new SqlFormat(mboremote, "wtnum = :wtnum");
		// mbosetremote.setWhere(sqlformat.format());
		// return mbosetremote;

		MboSetRemote changeFVSet = getMboServer().getMboSet(
				mboremote.getName(), getUserInfo());
		String sql = "CUWONUM=:CUWONUM";
		SqlFormat sqf = new SqlFormat(mboremote, sql);
		changeFVSet.setWhere(sqf.format());
		return changeFVSet;
	}

	protected Mbo getMboInstance(MboSet mboset) throws MXException,
			RemoteException {
		return new CuwoChangeStatus(mboset);
	}

	protected void changeMboStatus(MboRemote cuworemote, MboRemote param)
			throws MXException, RemoteException {
		((CuwoRemote) cuworemote).changeStatus(param.getString("status"), param
				.getDate("statdate"), param.getString("memo"));
	}
}